package servlet;

import service.UserService;
import service.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "ShopListDeleteServlet", value = "/shoppingList/delete")
public class ShopListDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/json; charset=utf-8");
        String id = request.getParameter("id");
        PrintWriter out = response.getWriter();
        UserService service = new UserServiceImpl();
        try {
            int result = service.deleteShoppingList(Integer.parseInt(id));
            if(result!=0){
                out.println("T");
            }else {
                out.println("F");
            }
        } catch (Exception e) {
            e.printStackTrace();
            out.println("E");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
